<!DOCTYPE html>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <title>活动列表</title>
    <link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="{$Think.config.RESOURCEURL}wx_assets/quan/product_list.css{$Think.config.RESOURCE_VER}" />
    <link href="{$Think.config.RESOURCEURL}wx_assets/dist/gmu.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/dist/gmu.min.js{$Think.config.RESOURCE_VER}"></script>
    <script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}"></script>
</head>
<body>
    <div id="container">
        <div id="productTabContent" class="productTabContent">
            <div class="productListBox" id="productListBox">  
            </div>
        </div>
    </div>
</body>
<script type="text/html" id="proTpl">

<% if (list && list.length>0 ) {
    for(var i=0;i<list.length;i++) {
        var item=list[i];
        item.saleCount=item.saleCount || 0;
    %>
    <div class="product" id="item_<%=item.id%>" style="height:90px">
        <div class="productImg">
            <a onclick="productList.goView('<%=item.fromCustomerId%>','<%=item.type%>','<%=item.id%>')">
                <img src="<%=item.picurl%>" onload="$.util.imgCenter(this)"/>
            </a>
        </div>
        <div class="productDetail">
            <div class="pro-left">
                <div class="productName" onclick="productList.goView('<%=item.fromCustomerId%>','<%=item.type%>','<%=item.id%>')"><%=item.activityname%></div>
            </div>
            <div class="pro-right">
                <div class="icon" style="margin-top:-8px"  onclick="productList.goView('<%=item.fromCustomerId%>','<%=item.type%>','<%=item.id%>')">
                    <div class="sj"></div>
                    <div class="upbtn">查看</div>
                </div>
            </div>
        </div>
    </div>
 <%}%>
<%} else {%>
    <div class="norecord">
        暂无相关活动信息
    </div>
<%}%>
</script>
<script type="text/javascript">
    var baseUrl = '{$Think.config.SERVER_HOST}';
    var productList={
        pageSize:10,
        init:function(){
            var me=this;
            this._initEvent();
            $.util.pageLoading.show();
            me._loadList(me.page,function(){
                $.util.pageLoading.hide();
            });
        },
        goView:function(fromCustomerId,type,actId){
            var params={
                "qId":"{$qId}",
                "miUId":"{$uid}",
                "actId":actId
            }
            params=encodeURIComponent(JSON.stringify(params));
            location.href= 'call.html?customerId='+fromCustomerId+'&module='+type+'&method=index&params='+params;
        },
        _initEvent:function(){
            var me=this;
            $.util.initDataLoading({
                me:productList,
                lastChildren:function(){
                    return $("#productListBox .product:last");
                },
                page:function(){
                    return productList.page; 
                },
                pageCount:function(){
                    return productList.pageCount;
                }
            });
        },
        _renderList:function(data,page,callback){
            var me=this;
           if(data){
                var html=template("proTpl", data),
                    container=$("#productListBox");
                container.append(html);
                me.page=page;
                me.pageCount=data.pageCount;
                callback && callback();
           }   
        },
        _loadList:function(page,callback){
            var me=this;
            $.req.get("call.json?module=quan&customerId={$customerId}&method=getActivilyList",{
                userName:"{$userName}",
                params:{
                    "qId":"{$qId}",
                    "start":page,
                    "limit":me.pageSize
                }
            },function(data){
                if(data){
                    me._renderList(data.proList,page,callback);
                }
            });
        },
        getShareUrl:function(){
            var shareUrl="";
            var params={
                "qId":"{$qId}",
                "fromUId":"{$fromUId}"
            };
            params=encodeURIComponent(JSON.stringify(params));
            shareUrl=baseUrl+'call.html?customerId={$customerId}&module=quan&scope=1&method=shopStart&params='+params;
            return shareUrl;
        }
    }
    productList.init();
    wx_share.init({
        "pkg":{
            "appId": '{$pkg.appId}',
            "timestamp": {$pkg.timestamp},
            "nonceStr": '{$pkg.nonceStr}',
            "signature": '{$pkg.signature}'
        },
        hide:1
    });
</script>
</html>